package com.example.community.dto;

import com.example.community.model.GiteeUser;
import com.example.community.model.User;
import lombok.Data;

@Data
public class UserDto {
    private String name;
    private Long id;
    private String bio;
    private String avatarUrl;
    private String ip;
    private Integer userType;

    public static UserDto getUserDtoByGiteeUser(GiteeUser giteeUser){
        UserDto userDto = new UserDto();
        userDto.setName(giteeUser.getName());
        userDto.setBio(giteeUser.getBio());
        userDto.setId(giteeUser.getId());
        userDto.setAvatarUrl(giteeUser.getAvatarUrl());
        userDto.setIp(giteeUser.getIp());
        userDto.setUserType(1);
        return userDto;
    }

    public static UserDto getUserDtoByUser(User user){
        UserDto userDto = new UserDto();
        userDto.setName(user.getName());
        userDto.setBio(user.getBio());
        userDto.setId(user.getId());
        userDto.setAvatarUrl(user.getPicUrl());
        userDto.setIp(user.getIp());
        userDto.setUserType(2);
        return userDto;
    }
}
